import numpy as np
from typing import List
import matplotlib.pyplot as plt
import math

def sample(n:int, N:int)->float:
    return math.sin(2 * math.pi * 3.4 * n / N)

samplesTimeDomain:List[float] = [sample(n, 64) for n in range(0, 64)]
samplesFrequencyDomainWithoutWindow:List[float] = [np.absolute(sample) for sample in np.fft.fft(samplesTimeDomain)]

def hanning(n:int, N:int)->float:
    return 0.5 - 0.5 * math.cos(2 * math.pi * n / N)
samplesTimeDomainWithHanningWindow:List[float] = [hanning(n, 64) * sample(n, 64) for n in range(0, 64)]
samplesFrequencyDomainWithHanningWindow:List[float] = [np.absolute(sample) for sample in np.fft.fft(samplesTimeDomainWithHanningWindow)]

# plt.plot(samplesTimeDomain, 'r.-', samplesTimeDomainWithHanningWindow, 'g.-')
plt.plot(samplesFrequencyDomainWithoutWindow, 'r.-', samplesFrequencyDomainWithHanningWindow, 'g.-')
plt.show()